package zjh.msg.entity;

import lombok.Data;
import lombok.experimental.Accessors;

import java.text.SimpleDateFormat;
import java.util.Date;

@Data
@Accessors(chain=true)
public class Msg {
    private Integer id;

    private String nickname;

    private String qq;

    private String email;

    private String text;

    private Integer replyId;

    private Date createTime;

    // 不从数据库映射，只在代码中动态生成
    private String formattedTime;

    public String getFormattedTime() {
        if (createTime != null) {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            return sdf.format(createTime);
        }
        return null;
    }

}